package com.wan.thread.async;

import java.util.concurrent.Future;
import java.util.function.Function;

public class AsyncResult<R>{

    private final Future<R> resultFuture;

    public AsyncResult(Future<R> resultFuture) {
        this.resultFuture = resultFuture;
    }

    public Future<R> getResultFuture() {
        return resultFuture;
    }

    public <NEXT>AsyncResult<NEXT> then(Function<R,NEXT> nextFunction){
        AsyncNextTask<R,NEXT> asyncNextTask = new AsyncNextTask<>(resultFuture, nextFunction);
        return AsyncExecutor.get().thenApply(asyncNextTask);
    }

    //TODO 合并等操作



}
